package nl.cmkprojects.sage.slimplayer;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Menu
{
  static private Pattern pattern = Pattern.compile("\\d+ of \\d+");
  private String menuName;
  private String menuItem;
  private int numberOfItems = 1;
  
  public Menu(String displayText)
  {
    super();
    String[] parts = displayText.split("[\n]");
    if (parts.length == 2)
    {
      menuName = parts[0];
      Matcher matcher = pattern.matcher(menuName);
      if (matcher.find())
      {
        String[] items = menuName.substring(matcher.start(), matcher.end()).split(" of ");
        numberOfItems = Integer.parseInt(items[1]);                
      }

      menuItem = parts[1];
    }
    else
    {
      menuName = parts[0];
      menuItem = "";
    }
  }

  public String getMenuItem()
  {
    return menuItem;
  }

  public String getMenuName()
  {
    return menuName;
  }

  public int getNumberOfItems()
  {
    return numberOfItems;
  }

}
